﻿<ResourceDictionary
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
    
    <Style x:Key="CheckBoxStyle" BasedOn="{StaticResource {x:Type CheckBox}}" TargetType="CheckBox">
        <Setter Property="Margin" Value="{DynamicResource DefaultTopMargin}" />
    </Style>

    <Style x:Key="ComboBoxStyle" BasedOn="{StaticResource {x:Type ComboBox}}" TargetType="ComboBox">
        <Setter Property="VerticalAlignment" Value="Center" />
        <Setter Property="Margin" Value="{DynamicResource DefaultTopMargin}" />
    </Style>

    <Style TargetType="Label">
        <Setter Property="HorizontalAlignment" Value="Right" />
        <Setter Property="Margin" Value="{DynamicResource DefaultTopMargin}" />
    </Style>

    <Style TargetType="PasswordBox">
        <Setter Property="VerticalAlignment" Value="Center" />
        <Setter Property="Margin" Value="{DynamicResource DefaultTopMargin}" />
        <Setter Property="Background" Value="{DynamicResource BackgroundBrush}" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate>
                    <Border BorderThickness="1" CornerRadius="2"
                            Padding="1"
                            Background="{DynamicResource BackgroundBrush}" BorderBrush="{DynamicResource BackgroundBrush}" >
                        <ScrollViewer Name="PART_ContentHost" />
                    </Border>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
    
    <Style x:Key="HyperlinkTextBlockStyle" BasedOn="{StaticResource {x:Type TextBlock}}" TargetType="TextBlock">
        <Setter Property="HorizontalAlignment" Value="Right" />
        <Setter Property="Margin" Value="{DynamicResource DefaultTopMargin}" />
    </Style>

    <Style x:Key="TextBoxStyle" BasedOn="{StaticResource {x:Type TextBox}}" TargetType="TextBox">
        <Setter Property="VerticalAlignment" Value="Center" />
        <Setter Property="Margin" Value="{DynamicResource DefaultTopMargin}" />
    </Style>

    <Style x:Key="ValidationTextBoxStyle" BasedOn="{StaticResource TextBoxStyle}" TargetType="TextBox">
        <Style.Triggers>
            <Trigger Property="Validation.HasError" Value="True">
                <Setter Property="ToolTip"
                        Value="{Binding RelativeSource={RelativeSource Self}, Path=(Validation.Errors)[0].ErrorContent}"/>
            </Trigger>
        </Style.Triggers>
    </Style>

    <Storyboard x:Key="Authentication_Waiting" RepeatBehavior="Forever">
        <ColorAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetProperty="(Shape.Fill).(SolidColorBrush.Color)">
            <SplineColorKeyFrame KeyTime="00:00:00.5000000" Value="#FFFFEB00" />
            <SplineColorKeyFrame KeyTime="00:00:01" Value="#FFFF8300" />
        </ColorAnimationUsingKeyFrames>
    </Storyboard>
    <Storyboard x:Key="Authentication_Failed">
        <ColorAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetProperty="(Shape.Fill).(SolidColorBrush.Color)">
            <SplineColorKeyFrame KeyTime="00:00:00.5000000" Value="#FFBE0606" />
        </ColorAnimationUsingKeyFrames>
    </Storyboard>
    <Storyboard x:Key="Authentication_Succeeded">
        <ColorAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetProperty="(Shape.Fill).(SolidColorBrush.Color)">
            <SplineColorKeyFrame KeyTime="00:00:00.5000000" Value="#FF5BE907" />
        </ColorAnimationUsingKeyFrames>
    </Storyboard>

    <Style x:Key="AuthenticationStyle">
        <Style.Triggers>
            <DataTrigger Value="Authenticating" Binding="{Binding AuthenticateStatus}">
                <DataTrigger.EnterActions>
                    <StopStoryboard BeginStoryboardName="SBFailed" />
                    <StopStoryboard BeginStoryboardName="SBSucceeded" />
                    <BeginStoryboard Name="SBWaiting" Storyboard="{StaticResource Authentication_Waiting}" />
                </DataTrigger.EnterActions>
            </DataTrigger>
            <DataTrigger Value="Error" Binding="{Binding AuthenticateStatus}">
                <DataTrigger.EnterActions>
                    <StopStoryboard BeginStoryboardName="SBWaiting" />
                    <StopStoryboard BeginStoryboardName="SBSucceeded" />
                    <BeginStoryboard Name="SBFailed" Storyboard="{StaticResource Authentication_Failed}" />
                </DataTrigger.EnterActions>
            </DataTrigger>
            <DataTrigger Value="Success" Binding="{Binding AuthenticateStatus}">
                <DataTrigger.EnterActions>
                    <StopStoryboard BeginStoryboardName="SBWaiting" />
                    <StopStoryboard BeginStoryboardName="SBFailed" />
                    <BeginStoryboard Name="SBSucceeded" Storyboard="{StaticResource Authentication_Succeeded}" />
                </DataTrigger.EnterActions>
            </DataTrigger>
        </Style.Triggers>
    </Style>
</ResourceDictionary>